{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 把所有在train 和 test表内的events具体信息从events.csv表中取出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>event</th>\n",
       "      <th>invited</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>interested</th>\n",
       "      <th>not_interested</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3044012</td>\n",
       "      <td>1918771225</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3044012</td>\n",
       "      <td>1502284248</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3044012</td>\n",
       "      <td>2529072432</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3044012</td>\n",
       "      <td>3072478280</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3044012</td>\n",
       "      <td>1390707377</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      user       event  invited                         timestamp  interested  \\\n",
       "0  3044012  1918771225        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "1  3044012  1502284248        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "2  3044012  2529072432        0  2012-10-02 15:53:05.754000+00:00           1   \n",
       "3  3044012  3072478280        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "4  3044012  1390707377        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "\n",
       "   not_interested  \n",
       "0               0  \n",
       "1               0  \n",
       "2               0  \n",
       "3               0  \n",
       "4               0  "
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import csv\n",
    "import pandas as pd\n",
    "\n",
    "chunksize = 10**4\n",
    "train = pd.read_csv('train.csv')\n",
    "test = pd.read_csv('test.csv')\n",
    "uniqueEvents = pd.read_csv('UniqueEvents.csv')\n",
    "train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>event</th>\n",
       "      <th>invited</th>\n",
       "      <th>timestamp</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1776192</td>\n",
       "      <td>2877501688</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1776192</td>\n",
       "      <td>3025444328</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1776192</td>\n",
       "      <td>4078218285</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1776192</td>\n",
       "      <td>1024025121</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1776192</td>\n",
       "      <td>2972428928</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:21.985000+00:00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      user       event  invited                         timestamp\n",
       "0  1776192  2877501688        0  2012-11-30 11:39:01.230000+00:00\n",
       "1  1776192  3025444328        0  2012-11-30 11:39:01.230000+00:00\n",
       "2  1776192  4078218285        0  2012-11-30 11:39:01.230000+00:00\n",
       "3  1776192  1024025121        0  2012-11-30 11:39:01.230000+00:00\n",
       "4  1776192  2972428928        0  2012-11-30 11:39:21.985000+00:00"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(710, 110)\n",
      "(710, 110)\n",
      "(53, 110)\n",
      "(763, 110)\n",
      "(52, 110)\n",
      "(815, 110)\n",
      "(44, 110)\n",
      "(859, 110)\n",
      "(31, 110)\n",
      "(890, 110)\n",
      "(49, 110)\n",
      "(939, 110)\n",
      "(46, 110)\n",
      "(985, 110)\n",
      "(36, 110)\n",
      "(1021, 110)\n",
      "(57, 110)\n",
      "(1078, 110)\n",
      "(47, 110)\n",
      "(1125, 110)\n",
      "(38, 110)\n",
      "(1163, 110)\n",
      "(33, 110)\n",
      "(1196, 110)\n",
      "(31, 110)\n",
      "(1227, 110)\n",
      "(35, 110)\n",
      "(1262, 110)\n",
      "(39, 110)\n",
      "(1301, 110)\n",
      "(48, 110)\n",
      "(1349, 110)\n",
      "(41, 110)\n",
      "(1390, 110)\n",
      "(52, 110)\n",
      "(1442, 110)\n",
      "(50, 110)\n",
      "(1492, 110)\n",
      "(40, 110)\n",
      "(1532, 110)\n",
      "(41, 110)\n",
      "(1573, 110)\n",
      "(38, 110)\n",
      "(1611, 110)\n",
      "(39, 110)\n",
      "(1650, 110)\n",
      "(36, 110)\n",
      "(1686, 110)\n",
      "(32, 110)\n",
      "(1718, 110)\n",
      "(41, 110)\n",
      "(1759, 110)\n",
      "(42, 110)\n",
      "(1801, 110)\n",
      "(46, 110)\n",
      "(1847, 110)\n",
      "(42, 110)\n",
      "(1889, 110)\n",
      "(27, 110)\n",
      "(1916, 110)\n",
      "(39, 110)\n",
      "(1955, 110)\n",
      "(41, 110)\n",
      "(1996, 110)\n",
      "(39, 110)\n",
      "(2035, 110)\n",
      "(34, 110)\n",
      "(2069, 110)\n",
      "(41, 110)\n",
      "(2110, 110)\n",
      "(42, 110)\n",
      "(2152, 110)\n",
      "(42, 110)\n",
      "(2194, 110)\n",
      "(32, 110)\n",
      "(2226, 110)\n",
      "(47, 110)\n",
      "(2273, 110)\n",
      "(35, 110)\n",
      "(2308, 110)\n",
      "(42, 110)\n",
      "(2350, 110)\n",
      "(39, 110)\n",
      "(2389, 110)\n",
      "(39, 110)\n",
      "(2428, 110)\n",
      "(43, 110)\n",
      "(2471, 110)\n",
      "(54, 110)\n",
      "(2525, 110)\n",
      "(41, 110)\n",
      "(2566, 110)\n",
      "(49, 110)\n",
      "(2615, 110)\n",
      "(41, 110)\n",
      "(2656, 110)\n",
      "(48, 110)\n",
      "(2704, 110)\n",
      "(43, 110)\n",
      "(2747, 110)\n",
      "(50, 110)\n",
      "(2797, 110)\n",
      "(38, 110)\n",
      "(2835, 110)\n",
      "(38, 110)\n",
      "(2873, 110)\n",
      "(35, 110)\n",
      "(2908, 110)\n",
      "(29, 110)\n",
      "(2937, 110)\n",
      "(41, 110)\n",
      "(2978, 110)\n",
      "(40, 110)\n",
      "(3018, 110)\n",
      "(44, 110)\n",
      "(3062, 110)\n",
      "(42, 110)\n",
      "(3104, 110)\n",
      "(42, 110)\n",
      "(3146, 110)\n",
      "(47, 110)\n",
      "(3193, 110)\n",
      "(28, 110)\n",
      "(3221, 110)\n",
      "(35, 110)\n",
      "(3256, 110)\n",
      "(39, 110)\n",
      "(3295, 110)\n",
      "(46, 110)\n",
      "(3341, 110)\n",
      "(41, 110)\n",
      "(3382, 110)\n",
      "(41, 110)\n",
      "(3423, 110)\n",
      "(33, 110)\n",
      "(3456, 110)\n",
      "(37, 110)\n",
      "(3493, 110)\n",
      "(52, 110)\n",
      "(3545, 110)\n",
      "(39, 110)\n",
      "(3584, 110)\n",
      "(54, 110)\n",
      "(3638, 110)\n",
      "(40, 110)\n",
      "(3678, 110)\n",
      "(42, 110)\n",
      "(3720, 110)\n",
      "(39, 110)\n",
      "(3759, 110)\n",
      "(37, 110)\n",
      "(3796, 110)\n",
      "(43, 110)\n",
      "(3839, 110)\n",
      "(43, 110)\n",
      "(3882, 110)\n",
      "(44, 110)\n",
      "(3926, 110)\n",
      "(44, 110)\n",
      "(3970, 110)\n",
      "(34, 110)\n",
      "(4004, 110)\n",
      "(49, 110)\n",
      "(4053, 110)\n",
      "(52, 110)\n",
      "(4105, 110)\n",
      "(32, 110)\n",
      "(4137, 110)\n",
      "(49, 110)\n",
      "(4186, 110)\n",
      "(38, 110)\n",
      "(4224, 110)\n",
      "(48, 110)\n",
      "(4272, 110)\n",
      "(38, 110)\n",
      "(4310, 110)\n",
      "(32, 110)\n",
      "(4342, 110)\n",
      "(42, 110)\n",
      "(4384, 110)\n",
      "(46, 110)\n",
      "(4430, 110)\n",
      "(32, 110)\n",
      "(4462, 110)\n",
      "(30, 110)\n",
      "(4492, 110)\n",
      "(39, 110)\n",
      "(4531, 110)\n",
      "(42, 110)\n",
      "(4573, 110)\n",
      "(41, 110)\n",
      "(4614, 110)\n",
      "(37, 110)\n",
      "(4651, 110)\n",
      "(37, 110)\n",
      "(4688, 110)\n",
      "(31, 110)\n",
      "(4719, 110)\n",
      "(37, 110)\n",
      "(4756, 110)\n",
      "(50, 110)\n",
      "(4806, 110)\n",
      "(45, 110)\n",
      "(4851, 110)\n",
      "(54, 110)\n",
      "(4905, 110)\n",
      "(39, 110)\n",
      "(4944, 110)\n",
      "(37, 110)\n",
      "(4981, 110)\n",
      "(36, 110)\n",
      "(5017, 110)\n",
      "(48, 110)\n",
      "(5065, 110)\n",
      "(51, 110)\n",
      "(5116, 110)\n",
      "(49, 110)\n",
      "(5165, 110)\n",
      "(48, 110)\n",
      "(5213, 110)\n",
      "(38, 110)\n",
      "(5251, 110)\n",
      "(41, 110)\n",
      "(5292, 110)\n",
      "(46, 110)\n",
      "(5338, 110)\n",
      "(43, 110)\n",
      "(5381, 110)\n",
      "(44, 110)\n",
      "(5425, 110)\n",
      "(35, 110)\n",
      "(5460, 110)\n",
      "(34, 110)\n",
      "(5494, 110)\n",
      "(47, 110)\n",
      "(5541, 110)\n",
      "(41, 110)\n",
      "(5582, 110)\n",
      "(35, 110)\n",
      "(5617, 110)\n",
      "(40, 110)\n",
      "(5657, 110)\n",
      "(32, 110)\n",
      "(5689, 110)\n",
      "(44, 110)\n",
      "(5733, 110)\n",
      "(32, 110)\n",
      "(5765, 110)\n",
      "(35, 110)\n",
      "(5800, 110)\n",
      "(47, 110)\n",
      "(5847, 110)\n",
      "(32, 110)\n",
      "(5879, 110)\n",
      "(49, 110)\n",
      "(5928, 110)\n",
      "(39, 110)\n",
      "(5967, 110)\n",
      "(32, 110)\n",
      "(5999, 110)\n",
      "(53, 110)\n",
      "(6052, 110)\n",
      "(34, 110)\n",
      "(6086, 110)\n",
      "(41, 110)\n",
      "(6127, 110)\n",
      "(35, 110)\n",
      "(6162, 110)\n",
      "(35, 110)\n",
      "(6197, 110)\n",
      "(37, 110)\n",
      "(6234, 110)\n",
      "(40, 110)\n",
      "(6274, 110)\n",
      "(43, 110)\n",
      "(6317, 110)\n",
      "(40, 110)\n",
      "(6357, 110)\n",
      "(42, 110)\n",
      "(6399, 110)\n",
      "(44, 110)\n",
      "(6443, 110)\n",
      "(32, 110)\n",
      "(6475, 110)\n",
      "(48, 110)\n",
      "(6523, 110)\n",
      "(48, 110)\n",
      "(6571, 110)\n",
      "(36, 110)\n",
      "(6607, 110)\n",
      "(39, 110)\n",
      "(6646, 110)\n",
      "(44, 110)\n",
      "(6690, 110)\n",
      "(38, 110)\n",
      "(6728, 110)\n",
      "(38, 110)\n",
      "(6766, 110)\n",
      "(49, 110)\n",
      "(6815, 110)\n",
      "(51, 110)\n",
      "(6866, 110)\n",
      "(53, 110)\n",
      "(6919, 110)\n",
      "(31, 110)\n",
      "(6950, 110)\n",
      "(46, 110)\n",
      "(6996, 110)\n",
      "(44, 110)\n",
      "(7040, 110)\n",
      "(43, 110)\n",
      "(7083, 110)\n",
      "(42, 110)\n",
      "(7125, 110)\n",
      "(30, 110)\n",
      "(7155, 110)\n",
      "(43, 110)\n",
      "(7198, 110)\n",
      "(35, 110)\n",
      "(7233, 110)\n",
      "(43, 110)\n",
      "(7276, 110)\n",
      "(37, 110)\n",
      "(7313, 110)\n",
      "(35, 110)\n",
      "(7348, 110)\n",
      "(45, 110)\n",
      "(7393, 110)\n",
      "(49, 110)\n",
      "(7442, 110)\n",
      "(44, 110)\n",
      "(7486, 110)\n",
      "(47, 110)\n",
      "(7533, 110)\n",
      "(39, 110)\n",
      "(7572, 110)\n",
      "(41, 110)\n",
      "(7613, 110)\n",
      "(49, 110)\n",
      "(7662, 110)\n",
      "(45, 110)\n",
      "(7707, 110)\n",
      "(44, 110)\n",
      "(7751, 110)\n",
      "(46, 110)\n",
      "(7797, 110)\n",
      "(53, 110)\n",
      "(7850, 110)\n",
      "(47, 110)\n",
      "(7897, 110)\n",
      "(39, 110)\n",
      "(7936, 110)\n",
      "(40, 110)\n",
      "(7976, 110)\n",
      "(42, 110)\n",
      "(8018, 110)\n",
      "(34, 110)\n",
      "(8052, 110)\n",
      "(37, 110)\n",
      "(8089, 110)\n",
      "(45, 110)\n",
      "(8134, 110)\n",
      "(39, 110)\n",
      "(8173, 110)\n",
      "(42, 110)\n",
      "(8215, 110)\n",
      "(39, 110)\n",
      "(8254, 110)\n",
      "(43, 110)\n",
      "(8297, 110)\n",
      "(31, 110)\n",
      "(8328, 110)\n",
      "(37, 110)\n",
      "(8365, 110)\n",
      "(42, 110)\n",
      "(8407, 110)\n",
      "(48, 110)\n",
      "(8455, 110)\n",
      "(41, 110)\n",
      "(8496, 110)\n",
      "(34, 110)\n",
      "(8530, 110)\n",
      "(39, 110)\n",
      "(8569, 110)\n",
      "(34, 110)\n",
      "(8603, 110)\n",
      "(38, 110)\n",
      "(8641, 110)\n",
      "(38, 110)\n",
      "(8679, 110)\n",
      "(37, 110)\n",
      "(8716, 110)\n",
      "(41, 110)\n",
      "(8757, 110)\n",
      "(41, 110)\n",
      "(8798, 110)\n",
      "(49, 110)\n",
      "(8847, 110)\n",
      "(34, 110)\n",
      "(8881, 110)\n",
      "(52, 110)\n",
      "(8933, 110)\n",
      "(40, 110)\n",
      "(8973, 110)\n",
      "(40, 110)\n",
      "(9013, 110)\n",
      "(43, 110)\n",
      "(9056, 110)\n",
      "(31, 110)\n",
      "(9087, 110)\n",
      "(47, 110)\n",
      "(9134, 110)\n",
      "(38, 110)\n",
      "(9172, 110)\n",
      "(47, 110)\n",
      "(9219, 110)\n",
      "(46, 110)\n",
      "(9265, 110)\n",
      "(33, 110)\n",
      "(9298, 110)\n",
      "(49, 110)\n",
      "(9347, 110)\n",
      "(41, 110)\n",
      "(9388, 110)\n",
      "(46, 110)\n",
      "(9434, 110)\n",
      "(43, 110)\n",
      "(9477, 110)\n",
      "(43, 110)\n",
      "(9520, 110)\n",
      "(29, 110)\n",
      "(9549, 110)\n",
      "(43, 110)\n",
      "(9592, 110)\n",
      "(34, 110)\n",
      "(9626, 110)\n",
      "(37, 110)\n",
      "(9663, 110)\n",
      "(39, 110)\n",
      "(9702, 110)\n",
      "(30, 110)\n",
      "(9732, 110)\n",
      "(47, 110)\n",
      "(9779, 110)\n",
      "(46, 110)\n",
      "(9825, 110)\n",
      "(43, 110)\n",
      "(9868, 110)\n",
      "(42, 110)\n",
      "(9910, 110)\n",
      "(35, 110)\n",
      "(9945, 110)\n",
      "(36, 110)\n",
      "(9981, 110)\n",
      "(37, 110)\n",
      "(10018, 110)\n",
      "(40, 110)\n",
      "(10058, 110)\n",
      "(44, 110)\n",
      "(10102, 110)\n",
      "(54, 110)\n",
      "(10156, 110)\n",
      "(47, 110)\n",
      "(10203, 110)\n",
      "(44, 110)\n",
      "(10247, 110)\n",
      "(36, 110)\n",
      "(10283, 110)\n",
      "(43, 110)\n",
      "(10326, 110)\n",
      "(39, 110)\n",
      "(10365, 110)\n",
      "(46, 110)\n",
      "(10411, 110)\n",
      "(44, 110)\n",
      "(10455, 110)\n",
      "(23, 110)\n",
      "(10478, 110)\n",
      "(43, 110)\n",
      "(10521, 110)\n",
      "(39, 110)\n",
      "(10560, 110)\n",
      "(30, 110)\n",
      "(10590, 110)\n",
      "(30, 110)\n",
      "(10620, 110)\n",
      "(47, 110)\n",
      "(10667, 110)\n",
      "(39, 110)\n",
      "(10706, 110)\n",
      "(37, 110)\n",
      "(10743, 110)\n",
      "(25, 110)\n",
      "(10768, 110)\n",
      "(40, 110)\n",
      "(10808, 110)\n",
      "(37, 110)\n",
      "(10845, 110)\n",
      "(40, 110)\n",
      "(10885, 110)\n",
      "(37, 110)\n",
      "(10922, 110)\n",
      "(36, 110)\n",
      "(10958, 110)\n",
      "(40, 110)\n",
      "(10998, 110)\n",
      "(38, 110)\n",
      "(11036, 110)\n",
      "(40, 110)\n",
      "(11076, 110)\n",
      "(32, 110)\n",
      "(11108, 110)\n",
      "(57, 110)\n",
      "(11165, 110)\n",
      "(39, 110)\n",
      "(11204, 110)\n",
      "(42, 110)\n",
      "(11246, 110)\n",
      "(43, 110)\n",
      "(11289, 110)\n",
      "(45, 110)\n",
      "(11334, 110)\n",
      "(31, 110)\n",
      "(11365, 110)\n",
      "(45, 110)\n",
      "(11410, 110)\n",
      "(40, 110)\n",
      "(11450, 110)\n",
      "(40, 110)\n",
      "(11490, 110)\n",
      "(30, 110)\n",
      "(11520, 110)\n",
      "(41, 110)\n",
      "(11561, 110)\n",
      "(51, 110)\n",
      "(11612, 110)\n",
      "(38, 110)\n",
      "(11650, 110)\n",
      "(36, 110)\n",
      "(11686, 110)\n",
      "(35, 110)\n",
      "(11721, 110)\n",
      "(34, 110)\n",
      "(11755, 110)\n",
      "(33, 110)\n",
      "(11788, 110)\n",
      "(35, 110)\n",
      "(11823, 110)\n",
      "(52, 110)\n",
      "(11875, 110)\n",
      "(35, 110)\n",
      "(11910, 110)\n",
      "(38, 110)\n",
      "(11948, 110)\n",
      "(52, 110)\n",
      "(12000, 110)\n",
      "(38, 110)\n",
      "(12038, 110)\n",
      "(47, 110)\n",
      "(12085, 110)\n",
      "(45, 110)\n",
      "(12130, 110)\n",
      "(30, 110)\n",
      "(12160, 110)\n",
      "(47, 110)\n",
      "(12207, 110)\n",
      "(35, 110)\n",
      "(12242, 110)\n",
      "(41, 110)\n",
      "(12283, 110)\n",
      "(40, 110)\n",
      "(12323, 110)\n",
      "(45, 110)\n",
      "(12368, 110)\n",
      "(32, 110)\n",
      "(12400, 110)\n",
      "(33, 110)\n",
      "(12433, 110)\n",
      "(39, 110)\n",
      "(12472, 110)\n",
      "(40, 110)\n",
      "(12512, 110)\n",
      "(44, 110)\n",
      "(12556, 110)\n",
      "(43, 110)\n",
      "(12599, 110)\n",
      "(32, 110)\n",
      "(12631, 110)\n",
      "(39, 110)\n",
      "(12670, 110)\n",
      "(33, 110)\n",
      "(12703, 110)\n",
      "(35, 110)\n",
      "(12738, 110)\n",
      "(39, 110)\n",
      "(12777, 110)\n",
      "(46, 110)\n",
      "(12823, 110)\n",
      "(48, 110)\n",
      "(12871, 110)\n",
      "(40, 110)\n",
      "(12911, 110)\n",
      "(41, 110)\n",
      "(12952, 110)\n",
      "(45, 110)\n",
      "(12997, 110)\n",
      "(36, 110)\n",
      "(13033, 110)\n",
      "(42, 110)\n",
      "(13075, 110)\n",
      "(46, 110)\n",
      "(13121, 110)\n",
      "(41, 110)\n",
      "(13162, 110)\n",
      "(37, 110)\n",
      "(13199, 110)\n",
      "(42, 110)\n",
      "(13241, 110)\n",
      "(34, 110)\n",
      "(13275, 110)\n",
      "(40, 110)\n",
      "(13315, 110)\n",
      "(35, 110)\n",
      "(13350, 110)\n",
      "(38, 110)\n",
      "(13388, 110)\n",
      "(30, 110)\n",
      "(13418, 110)\n"
     ]
    }
   ],
   "source": [
    "result = pd.DataFrame()\n",
    "for chunk in pd.read_csv('events.csv',chunksize=chunksize):\n",
    "        result_part= uniqueEvents.merge(chunk,right_on=['event_id'],\n",
    "                               left_on=['event_id'],\n",
    "                               how='inner')\n",
    "        result=pd.concat([result,result_part])\n",
    "        print(result_part.shape)\n",
    "        print(result.shape)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>event_id</th>\n",
       "      <th>user_id</th>\n",
       "      <th>start_time</th>\n",
       "      <th>city</th>\n",
       "      <th>state</th>\n",
       "      <th>zip</th>\n",
       "      <th>country</th>\n",
       "      <th>lat</th>\n",
       "      <th>lng</th>\n",
       "      <th>c_1</th>\n",
       "      <th>...</th>\n",
       "      <th>c_92</th>\n",
       "      <th>c_93</th>\n",
       "      <th>c_94</th>\n",
       "      <th>c_95</th>\n",
       "      <th>c_96</th>\n",
       "      <th>c_97</th>\n",
       "      <th>c_98</th>\n",
       "      <th>c_99</th>\n",
       "      <th>c_100</th>\n",
       "      <th>c_other</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1386404286</td>\n",
       "      <td>1434745018</td>\n",
       "      <td>2012-10-30T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>389818573</td>\n",
       "      <td>2509568288</td>\n",
       "      <td>2012-10-30T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2491721612</td>\n",
       "      <td>328919249</td>\n",
       "      <td>2012-10-30T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1738754396</td>\n",
       "      <td>4012519948</td>\n",
       "      <td>2012-08-31T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1788118360</td>\n",
       "      <td>2651621313</td>\n",
       "      <td>2012-10-27T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 110 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     event_id     user_id                start_time city state  zip country  \\\n",
       "0  1386404286  1434745018  2012-10-30T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "1   389818573  2509568288  2012-10-30T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "2  2491721612   328919249  2012-10-30T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "3  1738754396  4012519948  2012-08-31T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "4  1788118360  2651621313  2012-10-27T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "\n",
       "   lat  lng  c_1   ...     c_92  c_93  c_94  c_95  c_96  c_97  c_98  c_99  \\\n",
       "0  NaN  NaN    0   ...        0     0     0     0     0     0     0     0   \n",
       "1  NaN  NaN    1   ...        0     0     0     0     0     0     0     0   \n",
       "2  NaN  NaN    1   ...        0     0     0     0     0     0     0     0   \n",
       "3  NaN  NaN    1   ...        0     0     0     0     0     0     0     0   \n",
       "4  NaN  NaN    1   ...        1     0     0     0     0     0     0     0   \n",
       "\n",
       "   c_100  c_other  \n",
       "0      0        5  \n",
       "1      0        8  \n",
       "2      0        9  \n",
       "3      0        9  \n",
       "4      0       11  \n",
       "\n",
       "[5 rows x 110 columns]"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>event_id</th>\n",
       "      <th>user_id</th>\n",
       "      <th>start_time</th>\n",
       "      <th>city</th>\n",
       "      <th>state</th>\n",
       "      <th>zip</th>\n",
       "      <th>country</th>\n",
       "      <th>lat</th>\n",
       "      <th>lng</th>\n",
       "      <th>c_1</th>\n",
       "      <th>...</th>\n",
       "      <th>c_92</th>\n",
       "      <th>c_93</th>\n",
       "      <th>c_94</th>\n",
       "      <th>c_95</th>\n",
       "      <th>c_96</th>\n",
       "      <th>c_97</th>\n",
       "      <th>c_98</th>\n",
       "      <th>c_99</th>\n",
       "      <th>c_100</th>\n",
       "      <th>c_other</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>3898095594</td>\n",
       "      <td>1975709184</td>\n",
       "      <td>2012-11-15T03:00:00.003Z</td>\n",
       "      <td>Santa Clara</td>\n",
       "      <td>CA</td>\n",
       "      <td>95053</td>\n",
       "      <td>United States</td>\n",
       "      <td>37.345</td>\n",
       "      <td>-121.934</td>\n",
       "      <td>13</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>163</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>3797370417</td>\n",
       "      <td>502740369</td>\n",
       "      <td>2012-11-03T04:00:00.003Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-7.417</td>\n",
       "      <td>109.233</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>414015310</td>\n",
       "      <td>3745245643</td>\n",
       "      <td>2012-07-21T19:00:00.000Z</td>\n",
       "      <td>Austin</td>\n",
       "      <td>TX</td>\n",
       "      <td>NaN</td>\n",
       "      <td>United States</td>\n",
       "      <td>30.267</td>\n",
       "      <td>-97.737</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2660812160</td>\n",
       "      <td>439179975</td>\n",
       "      <td>2012-09-20T00:00:00.001Z</td>\n",
       "      <td>Vancouver</td>\n",
       "      <td>BC</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Canada</td>\n",
       "      <td>49.281</td>\n",
       "      <td>-123.121</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>1916422039</td>\n",
       "      <td>4115852090</td>\n",
       "      <td>2012-10-15T00:00:00.003Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 110 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      event_id     user_id                start_time         city state  \\\n",
       "25  3898095594  1975709184  2012-11-15T03:00:00.003Z  Santa Clara    CA   \n",
       "26  3797370417   502740369  2012-11-03T04:00:00.003Z          NaN   NaN   \n",
       "27   414015310  3745245643  2012-07-21T19:00:00.000Z       Austin    TX   \n",
       "28  2660812160   439179975  2012-09-20T00:00:00.001Z    Vancouver    BC   \n",
       "29  1916422039  4115852090  2012-10-15T00:00:00.003Z          NaN   NaN   \n",
       "\n",
       "      zip        country     lat      lng  c_1   ...     c_92  c_93  c_94  \\\n",
       "25  95053  United States  37.345 -121.934   13   ...        0     0     0   \n",
       "26    NaN            NaN  -7.417  109.233    0   ...        0     0     0   \n",
       "27    NaN  United States  30.267  -97.737    1   ...        0     0     0   \n",
       "28    NaN         Canada  49.281 -123.121    1   ...        0     0     0   \n",
       "29    NaN            NaN     NaN      NaN    7   ...        0     0     0   \n",
       "\n",
       "    c_95  c_96  c_97  c_98  c_99  c_100  c_other  \n",
       "25     0     0     0     0     7      1      163  \n",
       "26     0     0     0     0     0      0      108  \n",
       "27     0     0     0     0     0      0       29  \n",
       "28     0     0     0     0     0      0       18  \n",
       "29     1     0     0     0     1      0       43  \n",
       "\n",
       "[5 rows x 110 columns]"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 13418 entries, 0 to 29\n",
      "Columns: 110 entries, event_id to c_other\n",
      "dtypes: float64(2), int64(103), object(5)\n",
      "memory usage: 11.4+ MB\n"
     ]
    }
   ],
   "source": [
    "result.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "result.to_csv('UniqueEventsInfo.csv',index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
